package com.example.minibom.controller;

import com.example.minibom.feign.BOMUsesOccurrenceFeign;
import com.huawei.innovation.rdm.coresdk.basic.enums.ConditionType;
import com.huawei.innovation.rdm.coresdk.basic.vo.QueryRequestVo;
import com.huawei.innovation.rdm.coresdk.basic.vo.RDMParamVO;
import com.huawei.innovation.rdm.coresdk.basic.vo.RDMResultVO;
import com.huawei.innovation.rdm.minibom.bean.entity.BOMUsesOccurence;
import com.huawei.innovation.rdm.minibom.dto.entity.BOMUsesOccurenceCreateDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/feign")
@RestController
public class BOMUsesOccurenceController {

    @Autowired
    private BOMUsesOccurrenceFeign bomUsesOccurrenceFeign;
    //分页查询bomoccurence信息
    //必要参数为bom_id,以及bomusesoccurence的id
    @RequestMapping(value = "bomUsesOccurence/find", method = RequestMethod.POST)
    public RDMResultVO find() {
        RDMParamVO<QueryRequestVo> var1 = new RDMParamVO<>();
        QueryRequestVo params = new QueryRequestVo();
        var1.setParams(params);
        return bomUsesOccurrenceFeign.find("BOMUsesOccurence", var1);
    }



    //根据bomoccurence id获取bomoccurence信息
    //eg.{"id":"777649399915356160"}
    @RequestMapping(value = "bomUsesOccurence/get", method = RequestMethod.POST)
    public RDMResultVO get(@RequestBody BOMUsesOccurence bomUsesOccurrence) {
        RDMParamVO<BOMUsesOccurence> var1 = new RDMParamVO<>();
        var1.setParams(bomUsesOccurrence);
        return bomUsesOccurrenceFeign.get("BOMUsesOccurence", var1);
    }

    //创建bomoccurence
//    请求示例：{"bomLink":{"id":"1","clazz":"BOMLink"}}
    @RequestMapping(value = "bomUsesOccurence/create", method = RequestMethod.POST)
    public RDMResultVO create(@RequestBody BOMUsesOccurenceCreateDTO dto) {
        RDMParamVO<BOMUsesOccurenceCreateDTO> var1 = new RDMParamVO<>();
        var1.setParams(dto);
        return bomUsesOccurrenceFeign.create("BOMUsesOccurence", var1);
    }

    //更新bomoccurence
    //eg.{"bomLink":{"id":"777492528818565120","clazz":"BOMLink","name":""},"id":"777619274469490688"}
    @RequestMapping(value = "bomUsesOccurence/update", method = RequestMethod.POST)
    public RDMResultVO update(@RequestBody BOMUsesOccurence bomUsesOccurrence) {
        RDMParamVO<BOMUsesOccurence> var1 = new RDMParamVO<>();
        var1.setParams(bomUsesOccurrence);
        return bomUsesOccurrenceFeign.update("BOMUsesOccurence", var1);
    }

    //删除bomoccurence
    //eg.{"id":"777619274469490688"}
    @RequestMapping(value = "bomUsesOccurence/delete", method = RequestMethod.POST)
    public RDMResultVO delete(@RequestBody BOMUsesOccurence bomUsesOccurrence) {
        RDMParamVO<BOMUsesOccurence> var1 = new RDMParamVO<>();
        var1.setParams(bomUsesOccurrence);
        return bomUsesOccurrenceFeign.delete("BOMUsesOccurence", var1);
    }

}
